how to change an array element in JavaScript